home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume2 / basic / part4 < prev    next >
Encoding:
Internet Message Format  |  1986-11-30  |  26.1 KB

  1. From: ukma!david (David Herron, NPR Lover)
  2. Subject: A BASIC interpretor (Part 4 of 4)
  3. Newsgroups: mod.sources
  4. Approved: john@genrad.UUCP
  5.  
  6. Mod.sources:  Volume 2, Issue 26
  7. Submitted by: ukma!david (David Herron)
  8.  
  9.  
  10. #! /bin/sh
  11. # This is a shell archive, meaning:
  12. # 1. Remove everything above the #! /bin/sh line.
  13. # 2. Save the resulting text in a file.
  14. # 3. Execute the file with /bin/sh (not csh) to create the files:
  15. #    bs2/bstokens.h
  16. #    bs2/lex.c
  17. #    bs2/makefile
  18. #    bs2/mkop.c
  19. #    bs2/mkop.sh
  20. #    bs2/mkrbop.c
  21. #    bs2/mksop.c
  22. #    bstest/tary.bs
  23. #    bstest/tdata.bs
  24. #    bstest/tdata.int
  25. #    bstest/tf.int
  26. #    bstest/tfor.bs
  27. #    bstest/tfor.int
  28. #    bstest/tgs.bs
  29. #    bstest/tgs.int
  30. #    bstest/tif.bs
  31. #    bstest/tif.int
  32. #    bstest/tloop.bs
  33. #    bstest/tloop.int
  34. #    bstest/trp.bs
  35. #    bstest/trp.int
  36. #    bstest/tst6.bs
  37. #    bstest/tst6.int
  38. #    bstest/twh.bs
  39. #    bstest/twh.int
  40. # This archive created: Tue Jul 30 13:03:40 1985
  41. export PATH; PATH=/bin:$PATH
  42. if test ! -d 'bs2'
  43. then
  44.     echo shar: creating directory "'bs2'"
  45.     mkdir 'bs2'
  46. fi
  47. echo shar: extracting "'bs2/bstokens.h'" '(1017 characters)'
  48. if test -f 'bs2/bstokens.h'
  49. then
  50.     echo shar: will not over-write existing file "'bs2/bstokens.h'"
  51. else
  52. sed 's/^X//' << \SHAR_EOF > 'bs2/bstokens.h'
  53. # define EQUAL 257
  54. # define NEQ 258
  55. # define LE 259
  56. # define LT 260
  57. # define GE 261
  58. # define WHILE 262
  59. # define GT 263
  60. # define OR 264
  61. # define AND 265
  62. # define NOT 266
  63. # define RET 267
  64. # define REPEAT 268
  65. # define IF 269
  66. # define THEN 270
  67. # define ELSE 271
  68. # define GOTO 272
  69. # define GOSUB 273
  70. # define UNTIL 274
  71. # define STOP 275
  72. # define END 276
  73. # define INTEGER 277
  74. # define REAL 278
  75. # define SCONST 279
  76. # define ELIHW 280
  77. # define LET 281
  78. # define SWORD 282
  79. # define PRINT 283
  80. # define INPUT 284
  81. # define DATA 285
  82. # define CFOR 286
  83. # define FOR 287
  84. # define TO 288
  85. # define STEP 289
  86. # define READ 290
  87. # define WRITE 291
  88. # define NEXT 292
  89. # define DEFINE 293
  90. # define LFUN 294
  91. # define SFUN 295
  92. # define FDEF 296
  93. # define SYMBOL 297
  94. # define DIM 298
  95. # define VALUE 299
  96. # define IWORD 300
  97. # define RWORD 301
  98. # define ROFC 302
  99. # define LOOP 303
  100. # define EXITIF 304
  101. # define ITOR 305
  102. # define RTOI 306
  103. # define ITOA 307
  104. # define RTOA 308
  105. # define LEAVE 309
  106. # define CONTINUE 310
  107. # define POOL 311
  108. # define UNARY 312
  109. SHAR_EOF
  110. if test 1017 -ne "`wc -c < 'bs2/bstokens.h'`"
  111. then
  112.     echo shar: error transmitting "'bs2/bstokens.h'" '(should have been 1017 characters)'
  113. fi
  114. fi # end of overwriting check
  115. echo shar: extracting "'bs2/lex.c'" '(3933 characters)'
  116. if test -f 'bs2/lex.c'
  117. then
  118.     echo shar: will not over-write existing file "'bs2/lex.c'"
  119. else
  120. sed 's/^X//' << \SHAR_EOF > 'bs2/lex.c'
  121. /* lex.c -- tokeniser
  122.  */
  123.  
  124. #include <stdio.h>
  125. #include <ctype.h>
  126. #include "bstokens.h"
  127.  
  128. #define gather(c)    { yytext[yyleng++] = c; }
  129. #define getdig(c)    { for(;isdigit(c);c=input()) gather(c); }
  130.  
  131. #define ERROR (-1) /* yacc won't know what -1 is, gaurantees a syntax error */
  132.  
  133. #define YYTXTSIZ    200
  134. char yytext[YYTXTSIZ];
  135. int yyleng;
  136. extern char *yylval;    /* to return values to Yacc with */
  137. extern FILE *bsin;
  138.  
  139. struct word {
  140.     int val;
  141.     char *name;
  142. } words[] = {
  143.     OR,"or",    AND,"and",    NOT,"not",    RET,"return",
  144.     IF,"if",    THEN,"then",    ELSE,"else",    WHILE,"while",
  145.     GOTO,"goto",    GOSUB,"gosub",    STOP,"stop",    END,"end",
  146.     LET,"let",    PRINT,"print",    INPUT,"input",    FOR,"for",
  147.     TO,"to",    STEP,"step",    READ,"read",    WRITE,"write",
  148.     NEXT,"next",    DATA,"data",    ELIHW,"elihw",    REPEAT,"repeat",
  149.     UNTIL,"until",    DEFINE,"define", LFUN,"longf",    SFUN,"shortf",
  150.     FDEF,"file",    DIM,"dim",    SYMBOL,"symbol", VALUE,"value",
  151.     ITOR,"itor",    ITOA,"itoa",    RTOI,"rtoi",    RTOA,"rtoa",
  152.     CONTINUE,"continue",        LEAVE,"leave",
  153.     LOOP,"loop",    EXITIF,"exitif",    POOL,"pool",
  154.     -1,0
  155. };
  156.  
  157. int yylex()
  158. {
  159.     char c;
  160.     int i,j,typ;
  161.  
  162.     yylval = &yytext[0];
  163. loop:
  164.     c=input();
  165.             /* tab, or space */
  166.     if(c=='\t' || c==' ')
  167.     goto loop;
  168.             /* numbers start with a digit or a dot */
  169.     else if(isdigit(c) || c=='.')
  170.     {
  171.     yyleng=0;
  172.     typ=INTEGER;
  173.     getdig(c);
  174.     if(c == '.')
  175.     {
  176.         typ = REAL;
  177.         gather(c);
  178.         c = input();
  179.         getdig(c);
  180.     }
  181.     /* at this point, SOME digits must have been read, or else error */
  182.     if(yyleng==1 && yytext[0]=='.') goto reterr; /* only "." read */
  183.     if(yyleng == 0) goto reterr;
  184.     j = yyleng;        /* save end of first part */
  185.     if(c=='e' || c=='E')    /* number raised to something */
  186.     {
  187.         typ = REAL;
  188.         gather(c);
  189.         c = input();
  190.         if(c=='-' || c=='+') {gather(c); c=input(); }
  191.         getdig(c);
  192.         /* if no digits read since end of first part,
  193.          * then there is an error
  194.          */
  195.         for(i=yyleng; i>=j; i--)
  196.         if(isdigit(yytext[i]))
  197.             break;
  198.         if(i <= j) goto reterr;
  199.     }
  200.     unput(c);
  201.     gather('\0');
  202.     yylval = malloc(yyleng);
  203.     strcpy(yylval,yytext);
  204.     return(typ);
  205. reterr:
  206.     yyerror("badly formed number\n");
  207.     return(ERROR);
  208.     }
  209.             /* word of some kind */
  210.     else if(isalpha(c))
  211.     {
  212.     yyleng=0;
  213.     gather(c);
  214.     for(c=input(); isalpha(c) || isdigit(c) || c=='$' || c=='%'; c=input())
  215.         gather(c);
  216.     unput(c);
  217.     gather('\0');
  218.  
  219.     fold(yytext);
  220.     for(i=0; words[i].val!=-1; i++)
  221.         if(strcmp(yytext,words[i].name)==0)
  222.             break;
  223.     yylval = malloc(yyleng);
  224.     strcpy(yylval,yytext);
  225.     if(words[i].val != -1)
  226.         return(words[i].val);
  227.     else
  228.         switch(yytext[yyleng-2]) {
  229.         case '$': return(SWORD);
  230.         case '%': return(IWORD);
  231.         default: return(RWORD);
  232.         }
  233.     }
  234.             /* string constant */
  235.     else if(c == '\"')
  236.     {
  237.     yyleng=0;
  238.     for(c=input(); ;c=input())
  239.     {
  240.         if(c == '\"')
  241.         if((c=input()) == '\"')
  242.         {
  243.             gather('\\');
  244.             gather('\"');
  245.         }
  246.         else break;
  247.         else if(c == '\\')
  248.         {
  249.         gather('\\');
  250.         c=input();
  251.         gather(c);
  252.         if(c == '\n') rdlin(bsin);
  253.         }
  254.         else if(c == '\n')
  255.         {
  256.         fprintf(stderr,"unclosed string constant: %s\n",yytext);
  257.         rdlin(bsin);
  258.         return(ERROR);
  259.         }
  260.         else gather(c);
  261.     }
  262.     unput(c);
  263.     gather('\0');
  264.     yylval = malloc(yyleng);
  265.     strcpy(yylval,yytext);
  266.     return(SCONST);
  267.     }
  268.     else if(c == '=')
  269.                 /* EQUAL == '==' */
  270.     if((c=input()) == '=')
  271.         return(EQUAL);
  272.                 /* ASSIGN == '=' */
  273.     else
  274.         { unput(c); return('='); }
  275.     else if(c == '<')
  276.                 /* NEQ == '<>' */
  277.     if((c=input()) == '>')
  278.         return(NEQ);
  279.                 /* LE == '<=' */
  280.     else if(c == '=')
  281.         return(LE);
  282.                 /* LT == '<' */
  283.     else
  284.         { unput(c); return(LT); }
  285.     else if(c == '>')
  286.                 /* GE == '>=' */
  287.     if((c=input()) == '=')
  288.         return(GE);
  289.                 /* GT == '>' */
  290.     else
  291.         { unput(c); return(GT); }
  292.             /* anything else */
  293.     else return(c);
  294. }
  295.  
  296. /* fold(s) -- change string to all lower-case letters.
  297.  */
  298. fold(s) char *s;
  299. {
  300.     int i;
  301.     for(i=0; s[i]!='\0'; i++)
  302.     if(isupper(s[i]))
  303.         s[i] = s[i] + ('a'-'A');
  304.     return(s);
  305. }
  306. SHAR_EOF
  307. if test 3933 -ne "`wc -c < 'bs2/lex.c'`"
  308. then
  309.     echo shar: error transmitting "'bs2/lex.c'" '(should have been 3933 characters)'
  310. fi
  311. fi # end of overwriting check
  312. echo shar: extracting "'bs2/makefile'" '(651 characters)'
  313. if test -f 'bs2/makefile'
  314. then
  315.     echo shar: will not over-write existing file "'bs2/makefile'"
  316. else
  317. sed 's/^X//' << \SHAR_EOF > 'bs2/makefile'
  318. OFILES = lex.o bsint.o action.o operat.o bslib.o errors.o
  319. PRSO= bsgram.o lex.o bslib.o
  320. INTO= bsint.o action.o operat2.o operat.o bslib.o errors.o
  321.  
  322. all: prs int
  323. prs: ${PRSO}
  324.     cc -s ${PRSO} -o prs
  325. bsgram.o: bsgram.c bsdefs.h
  326.     cc -c bsgram.c
  327. bsgram.c: bsgram.y
  328.     yacc -d bsgram.y
  329.     mv y.tab.c bsgram.c
  330.     mv y.tab.h bstokens.h
  331.  
  332. int: ${INTO}
  333.     cc ${INTO} -o int
  334.  
  335. ${OFILES}: bsdefs.h
  336.  
  337. operat2.o: mkop.c mkrbop.c mksop.c mkop.sh bsdefs.h
  338.     cc mkop.c -o op
  339.     cc mkrbop.c -o rop
  340.     cc mksop.c -o sop
  341.     mkop.sh >operat2.c
  342.     cc -c operat2.c
  343.     rm operat2.c op sop rop
  344.  
  345. pr:
  346.     pr bsgram.y lex.c bsdefs.h bslib.c bsint.c action.c operat.c mkop.c mkrbop.c mksop.c errors.c | lpr
  347. SHAR_EOF
  348. if test 651 -ne "`wc -c < 'bs2/makefile'`"
  349. then
  350.     echo shar: error transmitting "'bs2/makefile'" '(should have been 651 characters)'
  351. fi
  352. fi # end of overwriting check
  353. echo shar: extracting "'bs2/mkop.c'" '(1199 characters)'
  354. if test -f 'bs2/mkop.c'
  355. then
  356.     echo shar: will not over-write existing file "'bs2/mkop.c'"
  357. else
  358. sed 's/^X//' << \SHAR_EOF > 'bs2/mkop.c'
  359. /* mkop.c -- make operator function for bs.
  360.  *
  361.  *    USAGE: op name type oper tag
  362.  *
  363.  * where:    name: name of function generated.
  364.  *        type: data type of operation.
  365.  *        oper: operator for operation.
  366.  *        tag: structure tag name.
  367.  *
  368.  * This will only work with T_INT and T_DBL operators, T_CHR operations
  369.  * do not boil down to a simple operation.
  370.  */
  371. #include <stdio.h>
  372.  
  373. main(argc,argv)
  374. char **argv;
  375. int argc;
  376. {
  377.     char *name,*type,*oper,*tag;
  378.  
  379.     if(argc != 5) {
  380.     fprintf(stderr,"arg count\n");
  381.     exit(1);
  382.     }
  383.     name = argv[1]; type = argv[2]; oper = argv[3]; tag = argv[4];
  384.  
  385.     printf("_%s(l,p)\n",name);
  386.     printf("int (*l[])(),p;\n");
  387.     printf("{\n");
  388.     printf("    union value rg1,rg2,result;\n");
  389.     printf("\n");
  390.     printf("    switch(status&XMODE) {\n");
  391.     printf("    case M_READ: dtype = T_%s;\n",type);
  392.     printf("    case M_EXECUTE:\n");
  393.     printf("        rg2 = pop();\n");
  394.     printf("        rg1 = pop();\n");
  395.     printf("        result.%s = rg1.%s %s rg2.%s;\n",tag,tag,oper,tag);
  396.     printf("        push(result);\n");
  397.     printf("    case M_FIXUP:\n");
  398.     printf("    case M_COMPILE: return(p);\n");
  399.     printf("    default: STerror(\"%s\");\n",name);
  400.     printf("    }\n");
  401.     printf("}\n");
  402. }
  403. SHAR_EOF
  404. if test 1199 -ne "`wc -c < 'bs2/mkop.c'`"
  405. then
  406.     echo shar: error transmitting "'bs2/mkop.c'" '(should have been 1199 characters)'
  407. fi
  408. fi # end of overwriting check
  409. echo shar: extracting "'bs2/mkop.sh'" '(791 characters)'
  410. if test -f 'bs2/mkop.sh'
  411. then
  412.     echo shar: will not over-write existing file "'bs2/mkop.sh'"
  413. else
  414. sed 's/^X//' << \SHAR_EOF > 'bs2/mkop.sh'
  415. echo "/* operat2.c -- more operators for bs.  the ones that are all alike."
  416. echo " */"
  417. echo ""
  418. echo "#include \"bsdefs.h\""
  419. echo ""
  420. op "iadd" "INT" "+" "ival"
  421. op "radd" "DBL" "+" "rval" 
  422. op "isub" "INT" "-" "ival" 
  423. op "rsub" "DBL" "-" "rval" 
  424. op "imult" "INT" "*" "ival" 
  425. op "rmult" "DBL" "*" "rval" 
  426. op "idiv" "INT" "/" "ival" 
  427. op "rdiv" "DBL" "/" "rval" 
  428. op "imod" "INT" "%" "ival" 
  429. op "ieq" "INT" "==" "ival" 
  430. rop "req" "=="
  431. sop "seq" "=="
  432. op "ineq" "INT" "!=" "ival" 
  433. rop "rneq" "!="
  434. sop "sneq" "!="
  435. op "ileq" "INT" "<=" "ival" 
  436. rop "rleq" "<="
  437. sop "sleq" "<="
  438. op "ilt" "INT" "<" "ival" 
  439. rop "rlt" "<"
  440. sop "slt" "<"
  441. op "igeq" "INT" ">=" "ival" 
  442. rop "rgeq" ">="
  443. sop "sgeq" ">="
  444. op "igt" "INT" ">" "ival" 
  445. rop "rgt" ">"
  446. sop "sgt" ">"
  447. op "or" "INT" "||" "ival" 
  448. op "and" "INT" "&&" "ival" 
  449. SHAR_EOF
  450. if test 791 -ne "`wc -c < 'bs2/mkop.sh'`"
  451. then
  452.     echo shar: error transmitting "'bs2/mkop.sh'" '(should have been 791 characters)'
  453. fi
  454. chmod +x 'bs2/mkop.sh'
  455. fi # end of overwriting check
  456. echo shar: extracting "'bs2/mkrbop.c'" '(987 characters)'
  457. if test -f 'bs2/mkrbop.c'
  458. then
  459.     echo shar: will not over-write existing file "'bs2/mkrbop.c'"
  460. else
  461. sed 's/^X//' << \SHAR_EOF > 'bs2/mkrbop.c'
  462. /* mkrbop.c -- make operator functions for bs.  (real-boolean functions.)
  463.  *
  464.  *    USAGE: op name oper
  465.  *
  466.  * where:    name: name of function generated.
  467.  *        oper: operator for operation.
  468.  */
  469. #include <stdio.h>
  470.  
  471. main(argc,argv)
  472. char **argv;
  473. int argc;
  474. {
  475.     char *name,*oper;
  476.  
  477.     if(argc != 3) {
  478.     fprintf(stderr,"arg count\n");
  479.     exit(1);
  480.     }
  481.     name = argv[1]; oper = argv[2];
  482.  
  483.     printf("_%s(l,p)\n",name);
  484.     printf("int (*l[])(),p;\n");
  485.     printf("{\n");
  486.     printf("    union value rg1,rg2,result;\n");
  487.     printf("\n");
  488.     printf("    switch(status&XMODE) {\n");
  489.     printf("    case M_READ: dtype = T_INT;\n");
  490.     printf("    case M_EXECUTE:\n");
  491.     printf("        rg2 = pop();\n");
  492.     printf("        rg1 = pop();\n");
  493.     printf("        result.ival = rg1.rval %s rg2.rval;\n",oper);
  494.     printf("        push(result);\n");
  495.     printf("    case M_FIXUP:\n");
  496.     printf("    case M_COMPILE: return(p);\n");
  497.     printf("    default: STerror(\"%s\");\n",name);
  498.     printf("    }\n");
  499.     printf("}\n");
  500. }
  501. SHAR_EOF
  502. if test 987 -ne "`wc -c < 'bs2/mkrbop.c'`"
  503. then
  504.     echo shar: error transmitting "'bs2/mkrbop.c'" '(should have been 987 characters)'
  505. fi
  506. fi # end of overwriting check
  507. echo shar: extracting "'bs2/mksop.c'" '(932 characters)'
  508. if test -f 'bs2/mksop.c'
  509. then
  510.     echo shar: will not over-write existing file "'bs2/mksop.c'"
  511. else
  512. sed 's/^X//' << \SHAR_EOF > 'bs2/mksop.c'
  513. /* mksop.c -- make string comparator functions for bs.
  514.  *
  515.  *    USAGE: op name oper
  516.  *
  517.  * where:    name: name of function generated.
  518.  *        oper: operator for operation.
  519.  */
  520. #include <stdio.h>
  521.  
  522. main(argc,argv)
  523. char **argv;
  524. int argc;
  525. {
  526.     char *name,*oper;
  527.  
  528.     if(argc != 3) {
  529.     fprintf(stderr,"arg count\n");
  530.     exit(1);
  531.     }
  532.     name = argv[1]; oper = argv[2];
  533.  
  534.     printf("_%s(l,p)\n",name);
  535.     printf("int (*l[])(),p;\n");
  536.     printf("{\n");
  537.     printf("    union value rg1,rg2,result;\n");
  538.     printf("\n");
  539.     printf("    switch(status&XMODE) {\n");
  540.     printf("    case M_EXECUTE:\n");
  541.     printf("        rg2 = pop();\n");
  542.     printf("        rg1 = pop();\n");
  543.     printf("        result.sval = strcmp(rg1.sval,rg2.sval) %s 0;\n",oper);
  544.     printf("        push(result);\n");
  545.     printf("    case M_FIXUP:\n");
  546.     printf("    case M_COMPILE: return(p);\n");
  547.     printf("    default: STerror(\"%s\");\n",name);
  548.     printf("    }\n");
  549.     printf("}\n");
  550. }
  551. SHAR_EOF
  552. if test 932 -ne "`wc -c < 'bs2/mksop.c'`"
  553. then
  554.     echo shar: error transmitting "'bs2/mksop.c'" '(should have been 932 characters)'
  555. fi
  556. fi # end of overwriting check
  557. if test ! -d 'bstest'
  558. then
  559.     echo shar: creating directory "'bstest'"
  560.     mkdir 'bstest'
  561. fi
  562. echo shar: extracting "'bstest/tary.bs'" '(113 characters)'
  563. if test -f 'bstest/tary.bs'
  564. then
  565.     echo shar: will not over-write existing file "'bstest/tary.bs'"
  566. else
  567. sed 's/^X//' << \SHAR_EOF > 'bstest/tary.bs'
  568. 10 a=1.0
  569. 20 b(3)=2.0
  570. 30 b(2)=1.0
  571. 40 b(1)=0.0
  572. 45 print rtoa(a),rtoa(b(3)),rtoa(b(2)),rtoa(b(1)),rtoa(b(5))
  573. 50 end
  574. SHAR_EOF
  575. if test 113 -ne "`wc -c < 'bstest/tary.bs'`"
  576. then
  577.     echo shar: error transmitting "'bstest/tary.bs'" '(should have been 113 characters)'
  578. fi
  579. fi # end of overwriting check
  580. echo shar: extracting "'bstest/tdata.bs'" '(134 characters)'
  581. if test -f 'bstest/tdata.bs'
  582. then
  583.     echo shar: will not over-write existing file "'bstest/tdata.bs'"
  584. else
  585. sed 's/^X//' << \SHAR_EOF > 'bstest/tdata.bs'
  586. 10 data 10,20,15,30,5,35,12,32,0
  587. 20 read i%
  588. 30 if i%==0 then goto 200
  589. 40 print itoa(i%),
  590. 50 goto 20
  591. 200 print "\nOut of data"
  592. 210 end
  593. SHAR_EOF
  594. if test 134 -ne "`wc -c < 'bstest/tdata.bs'`"
  595. then
  596.     echo shar: error transmitting "'bstest/tdata.bs'" '(should have been 134 characters)'
  597. fi
  598. fi # end of overwriting check
  599. echo shar: extracting "'bstest/tdata.int'" '(397 characters)'
  600. if test -f 'bstest/tdata.int'
  601. then
  602.     echo shar: will not over-write existing file "'bstest/tdata.int'"
  603. else
  604. sed 's/^X//' << \SHAR_EOF > 'bstest/tdata.int'
  605.  line 10  data  icon 10  dsep  icon 20  dsep  icon 15  dsep  icon 30  dsep  icon 5  dsep  icon 35  dsep  icon 12  dsep  icon 32  dsep  icon 0  dsep 
  606.  line 20  pushstate 16  var 64 i%  popstate 
  607.  line 30  var 64 i%  val 64  icon 0  i==  if  goto 200  else 
  608.  line 40  var 64 i%  val 64  itoa  scon "" ,  print 
  609.  line 50  goto 20 
  610.  line 200  scon "\nOut of data"  scon "\n" ;  print 
  611.  line 210  end 
  612. SHAR_EOF
  613. if test 397 -ne "`wc -c < 'bstest/tdata.int'`"
  614. then
  615.     echo shar: error transmitting "'bstest/tdata.int'" '(should have been 397 characters)'
  616. fi
  617. fi # end of overwriting check
  618. echo shar: extracting "'bstest/tf.int'" '(223 characters)'
  619. if test -f 'bstest/tf.int'
  620. then
  621.     echo shar: will not over-write existing file "'bstest/tf.int'"
  622. else
  623. sed 's/^X//' << \SHAR_EOF > 'bstest/tf.int'
  624.  line 5  scon "Start please."  scon "\n" ;  print 
  625.  line 6  input  var 32 a$  elst 
  626.  line 10  var 0 i  con 1  con 10000  con 0  con 0 for 
  627.  line 20  var 0 i  next 
  628.  line 30  scon "Done."  scon "\n" ;  print 
  629.  line 40  end 
  630. SHAR_EOF
  631. if test 223 -ne "`wc -c < 'bstest/tf.int'`"
  632. then
  633.     echo shar: error transmitting "'bstest/tf.int'" '(should have been 223 characters)'
  634. fi
  635. fi # end of overwriting check
  636. echo shar: extracting "'bstest/tfor.bs'" '(130 characters)'
  637. if test -f 'bstest/tfor.bs'
  638. then
  639.     echo shar: will not over-write existing file "'bstest/tfor.bs'"
  640. else
  641. sed 's/^X//' << \SHAR_EOF > 'bstest/tfor.bs'
  642. 5 for j% = 1 to 10
  643. 7 print itoa(j%);"    ";
  644. 10 for i% = 1 to 10
  645. 20 print itoa(i%);"   ";
  646. 30 next i%
  647. 32 print ""
  648. 35 next j%
  649. 50 end
  650. SHAR_EOF
  651. if test 130 -ne "`wc -c < 'bstest/tfor.bs'`"
  652. then
  653.     echo shar: error transmitting "'bstest/tfor.bs'" '(should have been 130 characters)'
  654. fi
  655. fi # end of overwriting check
  656. echo shar: extracting "'bstest/tfor.int'" '(565 characters)'
  657. if test -f 'bstest/tfor.int'
  658. then
  659.     echo shar: will not over-write existing file "'bstest/tfor.int'"
  660. else
  661. sed 's/^X//' << \SHAR_EOF > 'bstest/tfor.int'
  662.  line 5  var 64 j%  icon 1  icon 10  icon 0  rlabel FOR2 rlabel FOR1 enter icon 0 rlabel FOR1 dlabel FOR0 for 
  663.  line 7  var 64 j%  val 64  itoa  scon "    "  ;  scon "" ;  print 
  664.  line 10  var 64 i%  icon 1  icon 10  icon 0  rlabel FOR5 rlabel FOR4 enter icon 0 rlabel FOR4 dlabel FOR3 for 
  665.  line 20  var 64 i%  val 64  itoa  scon "   "  ;  scon "" ;  print 
  666.  line 30  dlabel FOR5  var 64 i%  next rlabel FOR3 goto dlabel FOR4 exitlp 
  667.  line 32  scon ""  scon "\n" ;  print 
  668.  line 35  dlabel FOR2  var 64 j%  next rlabel FOR0 goto dlabel FOR1 exitlp 
  669.  line 50  end 
  670. SHAR_EOF
  671. if test 565 -ne "`wc -c < 'bstest/tfor.int'`"
  672. then
  673.     echo shar: error transmitting "'bstest/tfor.int'" '(should have been 565 characters)'
  674. fi
  675. fi # end of overwriting check
  676. echo shar: extracting "'bstest/tgs.bs'" '(143 characters)'
  677. if test -f 'bstest/tgs.bs'
  678. then
  679.     echo shar: will not over-write existing file "'bstest/tgs.bs'"
  680. else
  681. sed 's/^X//' << \SHAR_EOF > 'bstest/tgs.bs'
  682. 10 a%=0
  683. 20 while ( a%<20 )
  684. 29 print itoa(a%),
  685. 30 gosub 100
  686. 31 print itoa(a%),
  687. 40 elihw
  688. 50 print "Done."
  689. 60 stop
  690. 100 a%=a%+1
  691. 110 return
  692. 120 end
  693. SHAR_EOF
  694. if test 143 -ne "`wc -c < 'bstest/tgs.bs'`"
  695. then
  696.     echo shar: error transmitting "'bstest/tgs.bs'" '(should have been 143 characters)'
  697. fi
  698. fi # end of overwriting check
  699. echo shar: extracting "'bstest/tgs.int'" '(408 characters)'
  700. if test -f 'bstest/tgs.int'
  701. then
  702.     echo shar: will not over-write existing file "'bstest/tgs.int'"
  703. else
  704. sed 's/^X//' << \SHAR_EOF > 'bstest/tgs.int'
  705.  line 10  var 64 a%  icon 0  store 64 pop 
  706.  line 20  loopto  var 64 a%  val 64  icon 20  i<  while 
  707.  line 29  var 64 a%  val 64  itoa  scon "    " ;  print 
  708.  line 30  gosub 100 
  709.  line 31  var 64 a%  val 64  itoa  scon "    " ;  print 
  710.  line 40  elihw 
  711.  line 50  scon "Done."  scon "\n" ;  print 
  712.  line 60  stop 
  713.  line 100  var 64 a%  var 64 a%  val 64  icon 1  i+  store 64 pop 
  714.  line 110  return 
  715.  line 120  end 
  716. SHAR_EOF
  717. if test 408 -ne "`wc -c < 'bstest/tgs.int'`"
  718. then
  719.     echo shar: error transmitting "'bstest/tgs.int'" '(should have been 408 characters)'
  720. fi
  721. fi # end of overwriting check
  722. echo shar: extracting "'bstest/tif.bs'" '(180 characters)'
  723. if test -f 'bstest/tif.bs'
  724. then
  725.     echo shar: will not over-write existing file "'bstest/tif.bs'"
  726. else
  727. sed 's/^X//' << \SHAR_EOF > 'bstest/tif.bs'
  728. 10 a=3.0
  729. 20 input b
  730. 30 if a==b then goto 100 else goto 70
  731. 40 print "failed"
  732. 50 stop
  733. 70 print rtoa(a);" != ";rtoa(b)
  734. 80 goto 20
  735. 100 print rtoa(a);" == ";rtoa(b)
  736. 110 goto 20
  737. 120 end
  738. SHAR_EOF
  739. if test 180 -ne "`wc -c < 'bstest/tif.bs'`"
  740. then
  741.     echo shar: error transmitting "'bstest/tif.bs'" '(should have been 180 characters)'
  742. fi
  743. fi # end of overwriting check
  744. echo shar: extracting "'bstest/tif.int'" '(538 characters)'
  745. if test -f 'bstest/tif.int'
  746. then
  747.     echo shar: will not over-write existing file "'bstest/tif.int'"
  748. else
  749. sed 's/^X//' << \SHAR_EOF > 'bstest/tif.int'
  750.  line 10  var 192 a  rcon 3.0  store 192 pop 
  751.  line 20  pushstate 4  var 192 b  popstate 
  752.  line 30  var 192 a  val 192  var 192 b  val 192  r==  rlabel IF0 if  goto 100  rlabel IF1 go@  dlabel IF0  goto 70  dlabel IF1 
  753.  line 40  scon "failed"  scon "\n" ;  print 
  754.  line 50  stop 
  755.  line 70  var 192 a  val 192  rtoa  scon " != "  ;  var 192 b  val 192  rtoa  ;  scon "\n" ;  print 
  756.  line 80  goto 20 
  757.  line 100  var 192 a  val 192  rtoa  scon " == "  ;  var 192 b  val 192  rtoa  ;  scon "\n" ;  print 
  758.  line 110  goto 20 
  759.  line 120  end 
  760. SHAR_EOF
  761. if test 538 -ne "`wc -c < 'bstest/tif.int'`"
  762. then
  763.     echo shar: error transmitting "'bstest/tif.int'" '(should have been 538 characters)'
  764. fi
  765. fi # end of overwriting check
  766. echo shar: extracting "'bstest/tloop.bs'" '(164 characters)'
  767. if test -f 'bstest/tloop.bs'
  768. then
  769.     echo shar: will not over-write existing file "'bstest/tloop.bs'"
  770. else
  771. sed 's/^X//' << \SHAR_EOF > 'bstest/tloop.bs'
  772. 10 loop
  773. 20    input a,b
  774. 30 exitif a==b
  775. 40    a% = rtoi(a)
  776. 50    b% = rtoi(b)
  777. 60    print "a:";(a);" a%:";(a%);" b:";(b);" b%:";(b%)
  778. 70 pool
  779. 80 print "Done."
  780. 90 end
  781. SHAR_EOF
  782. if test 164 -ne "`wc -c < 'bstest/tloop.bs'`"
  783. then
  784.     echo shar: error transmitting "'bstest/tloop.bs'" '(should have been 164 characters)'
  785. fi
  786. fi # end of overwriting check
  787. echo shar: extracting "'bstest/tloop.int'" '(618 characters)'
  788. if test -f 'bstest/tloop.int'
  789. then
  790.     echo shar: will not over-write existing file "'bstest/tloop.int'"
  791. else
  792. sed 's/^X//' << \SHAR_EOF > 'bstest/tloop.int'
  793.  line 10  rlabel LP2 rlabel LP1 enter dlabel LP0 
  794.  line 20  pushstate 4  var 192 a  var 192 b  popstate 
  795.  line 30  var 192 a  val 192  var 192 b  val 192  r==  not rlabel LP1 if 
  796.  line 40  var 64 a%  var 192 a  val 192  rtoi  store 64 pop 
  797.  line 50  var 64 b%  var 192 b  val 192  rtoi  store 64 pop 
  798.  line 60  scon "a:"  var 192 a  val 192  rtoa  ;  scon " a%:"  ;  var 64 a%  val 64  itoa  ;  scon " b:"  ;  var 192 b  val 192  rtoa  ;  scon " b%:"  ;  var 64 b%  val 64  itoa  ;  scon "\n" ;  print 
  799.  line 70  dlabel LP2 rlabel LP0 goto dlabel LP1 exitlp 
  800.  line 80  scon "Done."  scon "\n" ;  print 
  801.  line 90  end 
  802. SHAR_EOF
  803. if test 618 -ne "`wc -c < 'bstest/tloop.int'`"
  804. then
  805.     echo shar: error transmitting "'bstest/tloop.int'" '(should have been 618 characters)'
  806. fi
  807. fi # end of overwriting check
  808. echo shar: extracting "'bstest/trp.bs'" '(74 characters)'
  809. if test -f 'bstest/trp.bs'
  810. then
  811.     echo shar: will not over-write existing file "'bstest/trp.bs'"
  812. else
  813. sed 's/^X//' << \SHAR_EOF > 'bstest/trp.bs'
  814. 10 repeat
  815. 20 print "Guess ";
  816. 30 input a
  817. 40 until ( rtoi(a) == 20 )
  818. 50 end
  819. SHAR_EOF
  820. if test 74 -ne "`wc -c < 'bstest/trp.bs'`"
  821. then
  822.     echo shar: error transmitting "'bstest/trp.bs'" '(should have been 74 characters)'
  823. fi
  824. fi # end of overwriting check
  825. echo shar: extracting "'bstest/trp.int'" '(246 characters)'
  826. if test -f 'bstest/trp.int'
  827. then
  828.     echo shar: will not over-write existing file "'bstest/trp.int'"
  829. else
  830. sed 's/^X//' << \SHAR_EOF > 'bstest/trp.int'
  831.  line 10  rlabel REP1 rlabel REP2 enter dlabel REP0 
  832.  line 20  scon "Guess "  print 
  833.  line 30  pushstate 4  var 192 a  popstate 
  834.  line 40  dlabel REP1  var 192 a  val 192  rtoi  icon 20  i==  not rlabel REP0 if dlabel REP2 exitlp 
  835.  line 50  end 
  836. SHAR_EOF
  837. if test 246 -ne "`wc -c < 'bstest/trp.int'`"
  838. then
  839.     echo shar: error transmitting "'bstest/trp.int'" '(should have been 246 characters)'
  840. fi
  841. fi # end of overwriting check
  842. echo shar: extracting "'bstest/tst6.bs'" '(438 characters)'
  843. if test -f 'bstest/tst6.bs'
  844. then
  845.     echo shar: will not over-write existing file "'bstest/tst6.bs'"
  846. else
  847. sed 's/^X//' << \SHAR_EOF > 'bstest/tst6.bs'
  848. 5 l%=32000
  849. 6 h%=-32000
  850. 9 print "trailer==0, input one number at a time."
  851. 10 input a%
  852. 20 if a%==0 then goto 100
  853. 30 if a%<l% then goto 60 
  854. 40 if a%>h% then goto 80
  855. 41 print"made it through    l:";itoa(l%);"h:";itoa(h%);"a:";itoa(a%)
  856. 50 goto 10
  857. 60 l%=a%
  858. 61 print"a<l    l:";itoa(l%);"h:";itoa(h%);"a:";itoa(a%)
  859. 70 goto 10
  860. 80 h%=a%
  861. 81 print"a>h    l:";itoa(l%);"h:";itoa(h%);"a:";itoa(a%)
  862. 90 goto 10
  863. 100 print "low=";itoa(l%),"high=";itoa(h%)
  864. 110 end
  865. SHAR_EOF
  866. if test 438 -ne "`wc -c < 'bstest/tst6.bs'`"
  867. then
  868.     echo shar: error transmitting "'bstest/tst6.bs'" '(should have been 438 characters)'
  869. fi
  870. fi # end of overwriting check
  871. echo shar: extracting "'bstest/tst6.int'" '(1399 characters)'
  872. if test -f 'bstest/tst6.int'
  873. then
  874.     echo shar: will not over-write existing file "'bstest/tst6.int'"
  875. else
  876. sed 's/^X//' << \SHAR_EOF > 'bstest/tst6.int'
  877.  line 5  var 64 l%  icon 32000  store 64 pop 
  878.  line 6  var 64 h%  icon 32000  icon -1 i*  store 64 pop 
  879.  line 9  scon "trailer==0, input one number at a time."  scon "\n" ;  print 
  880.  line 10  pushstate 4  var 64 a%  popstate 
  881.  line 20  var 64 a%  val 64  icon 0  i==  rlabel IF0 if  rlabel LN100 goto  rlabel IF1 goto  dlabel IF0 dlabel IF1 
  882.  line 30  var 64 a%  val 64  var 64 l%  val 64  i<  rlabel IF2 if  rlabel LN60 goto  rlabel IF3 goto  dlabel IF2 dlabel IF3 
  883.  line 40  var 64 a%  val 64  var 64 h%  val 64  i>  rlabel IF4 if  rlabel LN80 goto  rlabel IF5 goto  dlabel IF4 dlabel IF5 
  884.  line 41  scon "made it through    l:"  var 64 l%  val 64  itoa  ;  scon "h:"  ;  var 64 h%  val 64  itoa  ;  scon "a:"  ;  var 64 a%  val 64  itoa  ;  scon "\n" ;  print 
  885.  line 50  rlabel LN10 goto 
  886.  line 60  var 64 l%  var 64 a%  val 64  store 64 pop 
  887.  line 61  scon "a<l    l:"  var 64 l%  val 64  itoa  ;  scon "h:"  ;  var 64 h%  val 64  itoa  ;  scon "a:"  ;  var 64 a%  val 64  itoa  ;  scon "\n" ;  print 
  888.  line 70  rlabel LN10 goto 
  889.  line 80  var 64 h%  var 64 a%  val 64  store 64 pop 
  890.  line 81  scon "a>h    l:"  var 64 l%  val 64  itoa  ;  scon "h:"  ;  var 64 h%  val 64  itoa  ;  scon "a:"  ;  var 64 a%  val 64  itoa  ;  scon "\n" ;  print 
  891.  line 90  rlabel LN10 goto 
  892.  line 100  scon "low="  var 64 l%  val 64  itoa  ;  scon "high="  ,  var 64 h%  val 64  itoa  ;  scon "\n" ;  print 
  893.  line 110  end 
  894. SHAR_EOF
  895. if test 1399 -ne "`wc -c < 'bstest/tst6.int'`"
  896. then
  897.     echo shar: error transmitting "'bstest/tst6.int'" '(should have been 1399 characters)'
  898. fi
  899. fi # end of overwriting check
  900. echo shar: extracting "'bstest/twh.bs'" '(201 characters)'
  901. if test -f 'bstest/twh.bs'
  902. then
  903.     echo shar: will not over-write existing file "'bstest/twh.bs'"
  904. else
  905. sed 's/^X//' << \SHAR_EOF > 'bstest/twh.bs'
  906. 9 print "Guess a number ";
  907. 10 input a
  908. 20 while ( rtoi(a) <> 20)
  909. 25 gosub 100
  910. 30 elihw
  911. 40 print "You guessed it!"
  912. 100 print "Do it again ";
  913. 110 input a
  914. 111 print "number is ";rtoa(a)
  915. 120 return
  916. 200 end
  917. SHAR_EOF
  918. if test 201 -ne "`wc -c < 'bstest/twh.bs'`"
  919. then
  920.     echo shar: error transmitting "'bstest/twh.bs'" '(should have been 201 characters)'
  921. fi
  922. fi # end of overwriting check
  923. echo shar: extracting "'bstest/twh.int'" '(549 characters)'
  924. if test -f 'bstest/twh.int'
  925. then
  926.     echo shar: will not over-write existing file "'bstest/twh.int'"
  927. else
  928. sed 's/^X//' << \SHAR_EOF > 'bstest/twh.int'
  929.  line 9  scon "Guess a number "  scon "" ;  print 
  930.  line 10  pushstate 4  var 192 a  popstate 
  931.  line 20  rlabel WH2 rlabel WH1 enter dlabel WH0  var 192 a  val 192  rtoi  icon 20  i<>  rlabel WH1 if 
  932.  line 25  rlabel LN100 gosub 
  933.  line 30  dlabel WH2 rlabel WH0 goto dlabel WH1 exitlp 
  934.  line 40  scon "You guessed it!"  scon "\n" ;  print 
  935.  line 100  scon "Do it again "  scon "" ;  print 
  936.  line 110  pushstate 4  var 192 a  popstate 
  937.  line 111  scon "number is "  var 192 a  val 192  rtoa  ;  scon "\n" ;  print 
  938.  line 120  return 
  939.  line 200  end 
  940. SHAR_EOF
  941. if test 549 -ne "`wc -c < 'bstest/twh.int'`"
  942. then
  943.     echo shar: error transmitting "'bstest/twh.int'" '(should have been 549 characters)'
  944. fi
  945. fi # end of overwriting check
  946. #    End of shell archive
  947. exit 0
  948.